use crate::dto;
use crate::http::client::{error, rpc};
use crate::http::route;
use reqwest::Method;
use std::sync::Arc;

pub struct EndpointWireguardConfigClient {
    rpc_client: Arc<rpc::Client>,
}

impl EndpointWireguardConfigClient {
    pub fn new(rpc_client: Arc<rpc::Client>) -> Self {
        Self { rpc_client }
    }

    pub async fn get(
        &self,
        request: &dto::endpoint_wireguard_config::action::GetRequest,
    ) -> Result<dto::core::endpoint_wireguard_config::EndpointWireguardConfig, error::Error> {
        self.rpc_client
            .call(
                route::PATH_ENDPOINT_WIREGUARD_CONFIG_GET,
                Method::POST,
                request,
                rpc::CallOptions::default(),
            )
            .await
    }

    pub async fn update(
        &self,
        request: &dto::endpoint_wireguard_config::action::UpdateRequest,
    ) -> Result<(), error::Error> {
        self.rpc_client
            .call(
                route::PATH_ENDPOINT_WIREGUARD_CONFIG_UPDATE,
                Method::POST,
                request,
                rpc::CallOptions::default(),
            )
            .await
    }
}
